<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/3/16
 * Time: 9:46
 */

echo "<title>9-4 定义类的方法</title>";
echo "<p style='text-align: center'><a href=\"index.php\"><font size=\"4\">目录</font></a></p>";
header("Content-type: text/html; charset=utf-8");
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";

class Car{
    public $speed = 0;
    //增加speedUp方法，使speed加10
    public function speedUp(){
        $this->speed +=10; // += 是缩写 也可以写成这样 $this->speed = $this->speed + 10;
    }
}
$car = new Car();
$car->speedUp();
echo $car->speed;




















